package agent;

import java.util.LinkedList;
import java.util.List;



public abstract class Problem <S extends State>{
   
    protected S initialState;
    //lista de acoes que é possivel executar sobre um estado
    protected List<Action> actions;     
    protected Heuristic heuristic;

    public Problem(S initialState, List<Action> actions) {
        this.initialState = initialState;
        this.actions = actions;
    }
    
    public abstract boolean isGoal(S state);
    
    public double computePathCost(List<Action> path){
        double cost = 0;
        
        for (Action action : path) {
            cost += action.getCost();
        }
        
        return cost;
    }
    
    /*
     *permite obter uma lista de estados sucessores validos,
     *para os quais é possivel transitar atravez da aplicacao
     *das acoes disponiveis.
     *por exemplom, no puzzel de 8 se a branca tiver no meio
     *devolve 4 estados
     */
    public Heuristic getHeuristic() {
        return heuristic;
    }

    public void setHeuristic(Heuristic heuristic) {
        this.heuristic = heuristic;
    }

    public S getInitialState() {
        return initialState;
    }
    
    public abstract List<S> executeActions (S state);

    
    
}
